<%--
  Created by IntelliJ IDEA.
  User: 86151
  Date: 2022/5/4
  Time: 15:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<!--
  Author: Minyoung
  CreateAt: 2021年10月14日23:44:45
  License: MIT
-->
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <title>Landing...</title>
    <link rel="stylesheet" href="/layui/css/style.css">
    <script src="/layui/js/yzm.js"></script>
</head>

<body>
<div class="container">
    <div class="form-warp">
        <form class="sign-in-form layui-form login-bottom">
            <h2 class="form-title">后台管理人员登录</h2>
            <input type="text" lay-verify="phone" name="phone" id="phone" value="17379795084" placeholder="手机号" autocomplete="off" class="inq"/>
            <input type="password" name="password" id="password" placeholder="密码" value="123456" autocomplete="off" class="inq"/>
            <div class="submit-btn">
                <button class="login-btn" id="button1" lay-submit="" lay-filter="login">立即登录</button>
            </div>
        </form>
        <form class="sign-up-form layui-form login-bottom">
            <h2 class="form-title">自媒体登录</h2>
            <input type="text" lay-verify="phone" name="phone2" id="phone2" value="17379795084" placeholder="手机号" autocomplete="off" class="inq"/>
            <input type="password" name="password2" id="password2" placeholder="密码" value="12345" autocomplete="off" class="inq"/>
            <a href="/media/register">没有账号？点击前往申请入驻</a>
            <div class="submit-btn">
                <button class="login-btn" id="button2" lay-submit="" lay-filter="login2">立即登录</button>
            </div>
        </form>
    </div>
    <div class="desc-warp">
        <div class="desc-warp-item sign-up-desc">
            <div class="content">
                <button id="sign-up-btn" onclick="y1()">自媒体登录</button>
            </div>
            <img src="${pageContext.request.contextPath}/static/loginindex/img/log.svg" alt="">
        </div>
        <div class="desc-warp-item sign-in-desc">
            <div class="content">
                <button id="sign-in-btn" onclick="y2()">后台管理人员登录</button>
            </div>
            <img src="${pageContext.request.contextPath}/static/loginindex/img/register.svg" alt="">
        </div>
    </div>
</div>
<script src="/layui/js/main.js"></script>
<script src="/layui/js/jquery-3.6.0.min.js"></script>
<script src="/layui/js/coco-message.js"></script>

</body>
<script src="/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','jquery'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        // 登录过期的时候，跳出ifram框架
        if (top.location != self.location) top.location = self.location;

        $('.bind-password').on('click', function () {
            if ($(this).hasClass('icon-5')) {
                $(this).removeClass('icon-5');
                $("input[name='password']").attr('type', 'password');
            } else {
                $(this).addClass('icon-5');
                $("input[name='password']").attr('type', 'text');
            }
        });

        $('.icon-nocheck').on('click', function () {
            if ($(this).hasClass('icon-check')) {
                $(this).removeClass('icon-check');
            } else {
                $(this).addClass('icon-check');
            }
        });

        // 后台管理员进行登录操作
        form.on('submit(login)', function (data) {
            data = data.field;
            if (data.phone == '') {
                layer.msg('登录手机号不能为空');
                return false;
            }
            if (data.password == '') {
                layer.msg('密码不能为空');
                return false;
            }
            /*if (data.captcha == '') {
                layer.msg('验证码不能为空');
                return false;
            }*/
            $.ajax({
                url: '/admin/login',
                type: 'post',
                data: data,
                dataType: 'json',
                success: function(result) {
                    if (result.code == '0') {
                        window.location = '/admin/index';
                    } else {
                        layer.msg(result.msg)
                    }
                }
            });

            return false;
        });
        //自媒体用户登录
        form.on('submit(login2)', function (data) {
            data = data.field;
            if (data.phone2 == '') {
                layer.msg('登录手机号不能为空');
                return false;
            }
            if (data.password2 == '') {
                layer.msg('密码不能为空');
                return false;
            }
            /*if (data.captcha == '') {
                layer.msg('验证码不能为空');
                return false;
            }*/
            $.ajax({
                url: '/user/login',
                type: 'post',
                data: data,
                dataType: 'json',
                success: function(result) {
                    if (result.code == '0') {
                        window.location = '/user/index';
                    } else {
                        layer.msg(result.msg)
                    }
                }
            });
            return false;
        });
    });
</script>
</html>
